#include "ainterpreter.h"

AInterpreter::AInterpreter(Api &api, QObject *parent)
	: _api(api), QObject(parent)
{

}

AInterpreter::~AInterpreter()
{

}

byte								AInterpreter::getProto() const
{
	return _proto;
}

byte								AInterpreter::getOp(Packet &pkg) const
{
	return (pkg.getData<byte>(1)[0]);
}

bool								AInterpreter::interpret(Packet &pkg)
{
	byte op = getOp(pkg);

    if (operatorsFunc.find(op) != operatorsFunc.end())
    {
        funcPtr fp = operatorsFunc[op];
        (this->*fp)(pkg);
        return true;
    }
	else
		qDebug() << "OP not linked";
    return false;
}